function bindEvents(bindings) {
    for (var i in bindings) {
        if (bindings[i].selector) {
            $$(bindings[i].element).on(bindings[i].event, bindings[i].selector, bindings[i].handler);
        } else {
            $$(bindings[i].element).on(bindings[i].event, bindings[i].handler);
        }
    }
}

var batchQuery = {
    initialize: function () {

        this.bindEvent()
        this.renderPage()
    },
    renderPage: function () {
        var imgList = ['./img/04.png', './img/05.png', './img/06.png', './img/07.png', './img/08.png', './img/09.png', './img/10.png', './img/11.png', './img/12.png', './img/13.png', './img/14.png', './img/15.png', './img/16.png',]
        var output = tplManager.renderTplById('tplImg', imgList);
        $$('#page-main').html(output)
    },
    bindEvent: function () {
        var bindings = [

            {
                'element': '.page',
                'event': 'click',
                'selector': '.test',
                'handler': this.openPop()
            }, {
                'element': '.pages',
                'event': 'click',
                'selector': '#province li',
                'handler': this.selectProvince()
            }
        ];
        utils.bindEvent(bindings);
    },
    openPop: function () {
        return function (event) {
            myApp.pickerModal('.picker-info')
        }
    },
    selectProvince() {
        var self = this
        return function (event) {
            // console.log($$(this).data('id'))
            // console.log($$(this).data('name'))
            var id = $$(this).data('id'),
                name = $$(this).data('name')

            self.provinceId = id
            $$('.test').html(name)
            myApp.closeModal('.picker-info')
        }
    },
    /**
     * 渲染
     */
    renderList: function (listJson, bool) {
        // console.log(tempId, template, listJson)
        var output = tplManager.renderTplById('tplFoodItem', listJson);
        // console.log(output)
        bool ? $$('#food-list').html(output) : $$('#food-list').append(output)
    }
}
batchQuery.initialize()